define(function () {
    'use strict';

    function ctrl($scope,$stateParams,$timeout,$ionicScrollDelegate,WebService, WZ_BASE_PATH) {

        var par = $scope.param = {};
        par.id = $stateParams['id'];
        par.type = $stateParams['type'];
        par.selectId =  $stateParams['selectId'];

        init();

        $scope.doRefresh = function() {
            init().finally(function(){
                $scope.$broadcast('scroll.refreshComplete');
            });
        };


        function init(){
            return WebService.wzContent(par.id).then(function(data){
                if(data && data.length > 0) {
                    $scope.item = data[0];
                    $scope.item.txt = $scope.item.txt.replace(new RegExp('src="/tf',"gm"), 'src="'+WZ_BASE_PATH+'tf');
                }
            });
        }

    }

    ctrl.$inject = ['$scope','$stateParams','$timeout','$ionicScrollDelegate','WebService', 'WZ_BASE_PATH'];
    return ctrl;
});